/*
 * Copyright 2010 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.androidpn.sdk;

/**
 * Class desciption here.
 * 
 * @author Sehwan Noh (sehnoh@gmail.com)
 */
public class Constants {

    public static final String SDK_PREFERENCES = "SdkPreferences";
    
    public static final String MaxId = "MAXID";

    // KEYS

    public static final String API_KEY = "API_KEY";

    public static final String XMPP_HOST = "XMPP_HOST";

    public static final String XMPP_PORT = "XMPP_PORT";

    public static final String UPLOAD_IDS = "UPLOAD_IDS";
    
    public static final String XMPP_USERNAME = "XMPP_USERNAME";

    public static final String XMPP_PASSWORD = "XMPP_PASSWORD";

    public static final String USER_KEY = "USER_KEY";

    public static final String DEVICE_ID = "DEVICE_ID";

    public static final String EMULATOR_DEVICE_ID = "EMULATOR_DEVICE_ID";

    public static final String NOTIFICATION_ICON = "NOTIFICATION_ICON";

    public static final String NOTIFICATION_SOUND = "NOTIFICATION_SOUND";

    public static final String CALLBACK_ACTIVITY_PACKAGE_NAME = "CALLBACK_ACTIVITY_PACKAGE_NAME";
    
    public static final String CALLBACK_ACTIVITY_CLASS_NAME = "CALLBACK_ACTIVITY_CLASS_NAME";

    // INTENTS
    public static final String[] TTYPES = {"comm1","comm2","consult","wea","replay","turn","match"};
    
    public static final String TTYPE_NOTICE  = TTYPES[0];
    public static final String TTYPE_REPORT  = TTYPES[1];
    public static final String TTYPE_CONSULT = TTYPES[2];
    public static final String TTYPE_WEATHER = TTYPES[3];
    public static final String TTYPE_REPLAY  = TTYPES[4];
    public static final String TTYPE_TURN    = TTYPES[5];
    public static final String TTYPE_MATCH   = TTYPES[6];
    
    public static final int LOAD_MODEL_PLAYER = 0;
    public static final int LOAD_MODEL_PLAYERGROUP = 1;
    public static final int LOAD_MODEL_MATCH = 2;
    public static final int LOAD_MODEL_SCORE = 3;
    public static final int LOAD_MODEL_GAME = 4;
    public static final int LOAD_INPORTNOTICE = 5;
    
    public static final int LOAD_MODEL_VERSION = 9;
	public static final int LOAD_MODEL_STAFF = 10;
	public static final int LOAD_MODEL_DEPARTMENT = 11;
	public static final int LOAD_MODEL_WORKGROUP = 12;
	public static final int LOAD_MODEL_IM = 13;
    
    public static final String LATESTSCORE = "SELECT CONCAT(S5.S5,';;',S6.S6,';;',IF(IFNULL(S7.S7,'')='',IF(IFNULL(S1.S1,'')='',S0.S0,CONCAT(S0.S0,'|',S1.S1)),CONCAT(S0.S0,'|',S1.S1,'|',S7.S7)),';;',"
    	+ " IF(IFNULL(S8.S8,'')='',IF(IFNULL(S4.S4,'')='',S3.S3,CONCAT(S3.S3,'|',S4.S4)),CONCAT(S3.S3,'|',S4.S4,'|',S8.S8))) " 
    	+ " FROM " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " T1.EN_SNAME S5 " 
    	+ " FROM ATP_MATCH T0 LEFT JOIN ATP_PLAYER T1 ON T0.PLAYER_A = T1.ID " 
    	+ " WHERE T0.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2))  " 
    	+ " )S5 " 
    	+ " INNER JOIN " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " T1.EN_SNAME S6 " 
    	+ " FROM ATP_MATCH T0 LEFT JOIN ATP_PLAYER T1 ON T0.PLAYER_B = T1.ID " 
    	+ " WHERE T0.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2) )  " 
    	+ " )S6 " 
    	+ " ON 1=1 " 
    	+ " LEFT JOIN  " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " SCORE_A S0 " 
    	+ " FROM ATP_SCORE T0 LEFT JOIN ATP_MATCH T1 ON T0.MATCH_ID = T1.ID " 
    	+ " WHERE T1.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2)) AND T0.NUM = 1 " 
    	+ " )S0 " 
    	+ " ON 1=1 " 
    	+ " LEFT JOIN " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " SCORE_A S1 " 
    	+ " FROM ATP_SCORE T0 LEFT JOIN ATP_MATCH T1 ON T0.MATCH_ID = T1.ID " 
    	+ " WHERE T1.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2) ) AND T0.NUM = 2 " 
    	+ " )S1 " 
    	+ " ON 1 = 1 " 
    	+ " LEFT JOIN " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " SCORE_A S7 " 
    	+ " FROM ATP_SCORE T0 LEFT JOIN ATP_MATCH T1 ON T0.MATCH_ID = T1.ID " 
    	+ " WHERE T1.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2)) AND T0.NUM = 3 " 
    	+ " )S7 " 
    	+ " ON 1 = 1 " 
    	+ " LEFT JOIN " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " SCORE_B S3 " 
    	+ " FROM ATP_SCORE T0 LEFT JOIN ATP_MATCH T1 ON T0.MATCH_ID = T1.ID " 
    	+ " WHERE T1.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2)) AND T0.NUM = 1 " 
    	+ " )S3 " 
    	+ " ON 1 = 1 " 
    	+ " LEFT JOIN " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " SCORE_B S4 " 
    	+ " FROM ATP_SCORE T0 LEFT JOIN ATP_MATCH T1 ON T0.MATCH_ID = T1.ID " 
    	+ " WHERE T1.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2) ) AND T0.NUM = 2 " 
    	+ " )S4 " 
    	+ " ON 1 = 1 " 
    	+ " LEFT JOIN " 
    	+ " ( " 
    	+ " SELECT " 
    	+ " SCORE_B S8 " 
    	+ " FROM ATP_SCORE T0 LEFT JOIN ATP_MATCH T1 ON T0.MATCH_ID = T1.ID " 
    	+ " WHERE T1.id =  (select max(id) from atp_match where num = (select max(num)  from atp_match where STATICS = 2) ) AND T0.NUM = 3 " 
    	+ " )S8 " 
    	+ " ON 1 = 1 " 
;


    
    public static final String MACH = "SELECT CONCAT(ifnull(ID,'')"
								    	+",';;',ifnull(IS_GROUP,'')"
								    	+",';;',ifnull(BEGIN_TIME,'')"
								    	+",';;',ifnull(CN_TITLE,'')"
								    	+",';;',ifnull(day,'')"
								    	+",';;',ifnull(EN_TITLE,'')"	
								    	+",';;',ifnull(IS_SEED,'')"
								    	+",';;',ifnull(MATCH_TIME,'')"
								    	+",';;',ifnull(SECTION_CN_NAME,'')"
								    	+",';;',ifnull(SECTION_EN_NAME,'')"
								    	+",';;',ifnull(STATICS,'')"
								    	+",';;',ifnull(TURN_ID,'')"
								    	+",';;',ifnull(VENUE_ID,'')"
								    	+",';;',ifnull(PLAYER_A,'')"
								    	+",';;',ifnull(PLAYER_RETAIL,'')"
								    	+",';;',ifnull(PLAYER_B,'')"
								    	+",';;',ifnull(WINNER,'')"
								    	+",';;',ifnull(GROUP_A,'')"
								    	+",';;',ifnull(GROUP_RETAIL,'')"
								    	+",';;',ifnull(GROUP_B,'')"
								    	+",';;',ifnull(GROUP_WINNER,'')"
								    	+",';;',ifnull(NUM,' '))"
								    	+" FROM atp_match "
//								    	+" WHERE day = DAYOFMONTH(curdate())";
								    	+" WHERE (PLAYER_A is not null and PLAYER_B is not null) "
    									+ "OR (GROUP_A is not null and GROUP_B is not null)";

    public static final String SCORE = "SELECT CONCAT(ifnull(T0.ID,'')"
    									+",';;',ifnull(T0.NUM,'')"
    									+",';;',ifnull(T0.SCORE_A,'')"
    									+",';;',ifnull(T0.SCORE_B,'')"
    									+",';;',ifnull(T0.SMALL_SCORE_A,'')"
    									+",';;',ifnull(T0.SMALL_SCORE_B,'')"
    									+",';;',ifnull(T0.MATCH_ID,' '))"
    									+" FROM atp_score T0 LEFT JOIN new_atp_match T1 ON T0.MATCH_ID = T1.ID ";
    									//+" WHERE 1=1 or T1.day = DAYOFMONTH(curdate()) limit 5";
//								    	+" WHERE T1.TURN_ID = 1 or 1=1";   
    
	public static final String PLAYER = "SELECT CONCAT(ifnull(T0.ID,'')"
		+",';;',ifnull(T0.CN_NAME,'')"
		+",';;',ifnull(T0.CN_SNAME,'')"
		+",';;',ifnull(T0.COUNTRY,'')"
		+",';;',ifnull(T0.EN_COUNTRY,'')"
		+",';;',ifnull(T0.EN_NAME,'')"
		+",';;',ifnull(T0.EN_SNAME,' ')"
		+",';;',ifnull(T0.SEED_NUMBER,' ')"
		+",';;',ifnull(T0.BAT,' ')"
		+",';;',ifnull(T0.BIRTHDAY,' ')"
		+",';;',ifnull(T0.BIRTH_ADDRESS,' ')"
		+",';;',ifnull(T0.EN_BIRTHADDRESS,' ')"
		+",';;',ifnull(T0.PERMANENT_ADDRESS,' ')"
		+",';;',ifnull(T0.EN_PERMANENTADDRESS,' ')"
		+",';;',ifnull(T0.HEIGHT,' ')"
		+",';;',ifnull(T0.WEIGHT,' ')"
		+",';;',ifnull(T0.NUM,' ')"
		+",';;',ifnull(T0.WILDCARD,' '))"
		+" FROM atp_player T0";
	
//	select ID,PLAYER_A,PLAYER_B,GROUP_SEED_NUMBER,GROUP_WILDCARD
//	FROM atp_player_group
	public static final String PLAYERGROUP = "SELECT CONCAT(ifnull(T0.ID,'')"
		+",';;',ifnull(T0.PLAYER_A,'')"
		+",';;',ifnull(T0.PLAYER_B,'')"
		+",';;',ifnull(T0.GROUP_SEED_NUMBER,'')"
		+",';;',ifnull(T0.GROUP_WILDCARD,' '))"
		+" FROM atp_player_group T0";
}
